<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!--#include file="inc/conn.asp"-->
<!--#include file="inc/admincheck.asp"-->
<%if session("admin")="" then
response.Write "<script LANGUAGE='javascript'>alert('网络超时或者您还没有登录请登录');window.location.href='login.asp';</script>"
response.End
else
if session("flag")>2 then
response.Write "<p align=center><font color=red>您没有此项目管理权限！</font></p>"
response.End
end if
end if%>
<!--#include file="inc/meta.asp"-->
<body>
<%
dim bkfolder
dim bkdbname
dim fso
dim folderpath,fso1,f
call main()
conn.close
set conn=nothing
sub main()
%>

<%
if request("action")="Backup" then
call backupdata()
else
%>
<div id="bodyright">
<table class="tableBorder" width="90%" border="0" align="center" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF">
<tr> 
<td height="25" align="center" background="images/admin_bg_1.gif"><b><font color="#ffffff">备份数据库</font></b></td>
</tr>
<tr>
<td width="100%" align="left" bgcolor="#E8F1FF" style="padding:5px 10px;">
<font color="#FF0000">注意：注意：备份数据需要FSO组件支持，FSO组件的相关帮助！所有路径都是相对与程序空间根目录的相对路径！此功能谨慎使用,可能在有些空间备份后,在本机上不能用ACCESS打开。</font></td>
</tr>
<form method="post" action="Backup.asp?action=Backup">
<tr>
<td width="100%" align="left" bgcolor="#E8F1FF" style="padding:5px 10px;">
当前数据库路径：<input type=text size=24 name=DBpath value="../db/database.mdb"> 
请正确添写您当前使用的数据库路径！<BR>
备份数据库目录：<input type=text size=24 name=bkfolder value="../Databackup">
如果目录不存在，程序将自动创建！<BR>
备份数据库名称：<input type=text size=24 name=bkDBname value="database.mdb">
如果备份目录有该文件，将覆盖，如果没有，程序将自动创建！
</td>
</tr>
<tr>
<td width="100%" align="center" bgcolor="#E8F1FF" style="padding:5px 10px;">
<input type="submit" class="formbutton" value="开始备份"></td>
</tr>
</form>
<tr>
<td width="100%" align="left" bgcolor="#E8F1FF" style="padding:5px 10px;">
在上面填写数据库路径及数据库完整名称，程序的默认数据库文件为 database.mdb<br>
您可以用这个功能来备份您的数据库，以保证数据的安全！<br></td>
</tr>
</table>
</div>
<%
end if
%>

<%
end sub

sub backupdata()
Dbpath=request.form("Dbpath")
Dbpath=server.mappath(Dbpath)
bkfolder=request.form("bkfolder")
bkdbname=request.form("bkdbname")
Set Fso=server.createobject("scripting.filesystemobject")
if fso.fileexists(dbpath) then
If CheckDir(bkfolder) = True Then
fso.copyfile dbpath,bkfolder& "\"& bkdbname
else
MakeNewsDir bkfolder
fso.copyfile dbpath,bkfolder& "\"& bkdbname
end if
response.write "<script LANGUAGE='javascript'>alert('数据库备份成功！');history.go(-1);</script>"
else
response.write "<script LANGUAGE='javascript'>alert('数据库备份失败，找不到您所需要备份的文件！');history.go(-1);</script>"
end if
end sub
Function CheckDir(FolderPath)
folderpath=Server.MapPath(".")&"\"&folderpath
Set fso1 = CreateObject("Scripting.FileSystemObject")
If fso1.FolderExists(FolderPath) then
CheckDir = True
Else
CheckDir = False
End if
Set fso1 = nothing
End Function
Function MakeNewsDir(foldername)
Set fso1 = CreateObject("Scripting.FileSystemObject")
Set f = fso1.CreateFolder(foldername)
MakeNewsDir = True
Set fso1 = nothing
End Function
%>
<!--#include file="copyright.asp"-->
</body>
<%call CloseConn()%>
</html>